home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekikoh Dennoh Club 1
/
Gekikoh Dennoh Club Vol. 1 (Japan).7z
/
Gekikoh Dennoh Club Vol. 1 (Japan) (Track 1).bin
/
kowin
/
archive
/
apl
/
gview120.lzh
/
gviewsrc.lzh
/
pi_load.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-02-12
|
2KB
|
84 lines
/* Copyright 1992 H.Ogasawara (COR.) */
#include <corlib.h>
#include <sys_doslib.h>
#include "gview.h"
static int sizex, sizey;
static unsigned char com[256];
static
size_check( fname )
char *fname;
{
int fn;
unsigned char *p;
if( (fn= OPEN( fname, 0 )) >= 0 ){
READ( fn, p= com, 256 );
CLOSE( fn );
if( *p != 'P' || p[1] != 'i' ){
GV_Err( "piフォーマットが違います" );
return FALSE;
}
for( com[255]= 0x1a ; *p != 0x1a ; p++ );
*p++= '\0';
for( com[255]= 0 ; *p != 0x00 ; p++ );
p++; /* skip 0 */
p++; /* skip 1 */
p++; /* 比率0 */
p++; /* 比率1 */
p++; /* skip 1 !=4 nopi */
p+= 4; /* 機種 'X68K' */
{
int len= (*p<<8)+p[1];
p+= 2; /* 機種ユニークヘッダサイズ */
for(; len-- ; p++ );
}
sizex= (*p<<8)+p[1]; p+= 2;
sizey= (*p<<8)+p[1]; p+= 2;
return TRUE;
}
GV_Err( "piオープンできません" );
return FALSE;
}
GVIEW *
GV_Load_Pi( fname )
char *fname;
{
if( size_check( fname ) ){
char *bufp;
GVIEW *gp;
extern unsigned char Pi_PaletteBuff[];
if( !(gp= GV_Alloc( sizex, sizey, WindowAttrGraphic16,
fname, com+2, 1024*3 )) ){
GV_Err( "メモリが足りません" );
return NULL;
}
if( PiLoad( fname, gp->buf, sizex*sizey+2048+3+128,
0, 0, -1, -1, 100, 3 ) < 0 ){
GV_Err( "pi展開エラー" );
MFREE( gp );
return NULL;
}
{
unsigned char *str= gp->base_palet,
*ptr= Pi_PaletteBuff;
int i;
for( i= 0 ; i< 16 ; i++, ptr+= 3 ){
*str++= ptr[1];
*str++= ptr[0];
*str++= ptr[2];
}
GV_BaseToPalet( gp );
}
{
unsigned short *str= gp->buf, *ptr= gp->buf+2048/2;
int len= sizex*sizey/2;
for(; len-- ; *str++= *ptr++ );
}
return gp;
}
return NULL;
}